﻿{include file="public/header"/}

<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i>
	首页 <span class="c-gray en">&gt;</span>
	广告位管理 <span class="c-gray en">&gt;</span>广告图片列表
	<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" >
		<i class="Hui-iconfont">&#xe68f;</i>
	</a>
</nav>
<div class="page-container">
	<div class="text-c">

	</div>
	<div class="cl pd-5 bg-1 bk-gray mt-20">
		<span class="l">
			<a class="btn btn-primary radius" onclick="pictureAdd('添加图片','pictureAdd','800','500','')" href="javascript:;"><i class="Hui-iconfont">&#xe600;</i> 添加图片</a>
		</span>

	</div>
	<div class="mt-20">
		<table class="table table-border table-bordered table-bg table-hover table-sort">
			<thead>
			<tr class="text-c">
				<th width="25"><input type="checkbox" name="" value=""></th>
				<th width="80">编号</th>
				<th width="100">标题</th>
				<th width="100">内容</th>
				<th width="100">添加时间</th>
				<th width="100">发布状态</th>
				<th width="120">操作</th>
			</tr>
			</thead>
			<tbody>
			{volist name="data" id="vo"}
			<tr class="text-c">
				<td><input type="checkbox" value="" name=""></td>
				<td>{$vo.id}</td>
				<td>{$vo.title}</td>
				<!--<td class="text-l"><u style="cursor:pointer" class="text-primary" onClick="article_edit('查看','article-zhang.html','10001')" title="查看">资讯标题</u></td>-->
				<td><img src="__STATIC__/images/{$vo.pic}" style="width: 60px; height: 90px;"></td>
				<td>{$vo.create_time}</td>
				<td class="td-status">
					{if $vo['state']==0}
					<span class="label label-success radius">已发布</span>
					{else/}
					<span class="label label-defaunt radius">未发布</span>
					{/if}
				</td>
				<td class="f-14 td-manage">
					{if $vo['state']==0}
					<a style="text-decoration:none" onClick="pictureStop(this,'{$vo.id}','{$vo.state}')" href="javascript:;" title="下架">
						<i class="Hui-iconfont">&#xe6de;</i>
					</a>
					{else/}
					<a style="text-decoration:none" onClick="pictureStart(this,'{$vo.id}','{$vo.state}')" href="javascript:;" title="上架">
						<i class="Hui-iconfont">&#xe6dc;</i>

					</a>
					{/if}
					<!--<a style="text-decoration:none" onClick="article_stop(this,'10001')" href="javascript:;" title="下架"><i class="Hui-iconfont">&#xe6de;</i></a>-->
					<a style="text-decoration:none" class="ml-5" onClick="pictureEdit('编辑','pictureEdit?id={$vo.id}','','500','400')" href="javascript:;" title="编辑"><i class="Hui-iconfont">&#xe6df;</i></a>
					<a style="text-decoration:none" class="ml-5" onClick="download('下载','download?id={$vo.id}')" href="javascript:;" title="下载"><i class="Hui-iconfont">&#xe6df;</i></a>
					<a title="删除" href="javascript:;" onclick="pictureDel(this,'{$vo.id}','')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a>
				</td>
			</tr>
			{/volist}
			</tbody>
		</table>
	</div>
	<div class="pagin">


	</div>
</div>

{include file="public/footer"/}

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="__STATIC__/admin/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="__STATIC__/admin/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="__STATIC__/admin/lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript">
    $(function(){
        $('.table-sort').dataTable({
            "aaSorting": [[ 1, "desc" ]],//默认第几个排序
            "bStateSave": true,//状态保存
            "aoColumnDefs": [
                // {"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
                {"orderable":false,"aTargets":[0,5]}// 制定列不参与排序
            ]
        });

    });
    // $('.table-sort').dataTable({
    //     "aaSorting": [[ 1, "desc" ]],//默认第几个排序
    //     "bStateSave": true,//状态保存
    //     "pading":false,
    //     "aoColumnDefs": [
    //         //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
    //         {"orderable":false,"aTargets":[0,8]}// 不参与排序的列
    //     ]
    // });

    /*图片-添加*/
    function pictureAdd(title,url,w,h){
        layer_show(title,url,w,h);
    }
    // function article_add(title,url,w,h){
    //     var index = layer.open({
    //         type: 2,
    //         title: title,
    //         content: url
    //     });
    //     layer.full(index);
    // }
    /*图片-编辑*/
    function pictureEdit(title,url,w,h){
        layer_show(title,url,w,h);
    }

    function download(obj, id) {
        layer.confirm("确认要下载吗？", function (index) {
            $.ajax({
                type: 'POST',
                data:{"id":id},
                url: 'download',
                dataType: 'json',
                success: function(data){
                    if (data.code == 200){
                        // $(obj).parents("tr").remove();
                        layer.msg('已下载！',{icon:1,time:1000});
                        setTimeout('window.location.reload()',1000);
                    }
                    if (data.code == 403){
                        // $(obj).parents("tr").remove();
                        layer.msg('删除失败！',{icon:2,time:1000});
                        setTimeout('window.location.reload()',1000);
                        return false;
                    }

                },
            });
        });
    }

    /*图片-删除*/
    function pictureDel(obj, id) {
        layer.confirm("确认要删除吗？", function (index) {
            $.ajax({
                type: 'POST',
                data:{"id":id},
                url: 'pictureDel',
                dataType: 'json',
                success: function(data){
                    if (data.code == 200){
                        // $(obj).parents("tr").remove();
                        layer.msg('已删除！',{icon:1,time:1000});
                        setTimeout('window.location.reload()',1000);
                    }
                    if (data.code == 403){
                        // $(obj).parents("tr").remove();
                        layer.msg('删除失败！',{icon:2,time:1000});
                        setTimeout('window.location.reload()',1000);
                        return false;
                    }

                },
            });
        });
    }

    /*图片-下架*/
    function pictureStop(obj,id,state) {
        var title = "上架";
        if (state == 0) {
            state = 1;
            title = "已下架！";
        } else if (state == 1) {
            state = 0;
        }
        layer.confirm('确认要下架吗？',function (index) {
            $.ajax({
                type: "post",
                data: {"id":id,"state":state},
                url: "pictureActive",
                dataType: "json",
                // async: false,
                success: function (data) {
                    if (data) {
                        // $(obj).parents("tr").remove();
                        layer.msg(title , {icon: 5});
                        setTimeout('window.location.reload()',1000);
                    } else {
                        layer.msg(title + '失败', {icon: 2});
                        setTimeout('window.location.reload()',1000);
                    }
                }
            });
        });
    }

    /*图片-上架*/
    function pictureStart(obj,id,state) {
        var title = "已上架！";
        if (state == 0) {
            state = 1;
            title = "下架";
        } else if (state == 1) {
            state = 0;
        }
        layer.confirm('确认要上架吗？',function (index) {
            $.ajax({
                type: "post",
                data: {"id":id,"state":state},
                url: "pictureActive",
                dataType: "json",
                // async: false,
                success: function (data) {
                    if (data) {
                        // $(obj).parents("tr").remove();
                        layer.msg(title , {icon: 6});
                        setTimeout('window.location.reload()',1000);
                    } else {
                        layer.msg(title + '失败', {icon: 2});
                        setTimeout('window.location.reload()',1000);
                    }
                }
            });
        });
    }
</script>
</body>

</html>